package com.yiqi.lottery.feature.mine.view;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import com.suozhang.framework.entity.bo.UserInfoBo;
import com.suozhang.framework.framework.AM;
import com.suozhang.framework.framework.BaseActivity;
import com.suozhang.framework.utils.T;
import com.suozhang.framework.widget.PowerfulEditText;
import com.yiqi.lottery.R;
import com.yiqi.lottery.entity.bo.TokenBo;
import com.yiqi.lottery.feature.login.view.LoginActivity;
import com.yiqi.lottery.feature.mine.contract.MineContract;
import com.yiqi.lottery.feature.mine.dependencies.mine.DaggerMineComponent;
import com.yiqi.lottery.feature.mine.dependencies.mine.MinePresenterModule;

import javax.inject.Inject;

public class EditPasswordActivity extends BaseActivity implements MineContract.View {


    @BindView(R.id.toolbar)
    Toolbar mToolbar;

    @Inject
    MineContract.Presenter mPresenter;
    @BindView(R.id.edt_user_edit_pwd_old)
    PowerfulEditText mEdtUserEditPwdOld;
    @BindView(R.id.edt_user_edit_pwd_new)
    PowerfulEditText mEdtUserEditPwdNew;
    @BindView(R.id.edt_user_edit_pwd_renew)
    PowerfulEditText mEdtUserEditPwdRenew;

    @Override
    protected int attachLayoutRes() {
        return R.layout.activity_edit_password;
    }

    @Override
    protected void initInjector() {
        DaggerMineComponent.builder().minePresenterModule(new MinePresenterModule(this)).build().inject(this);
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void initView() {
        initToolBar(mToolbar, "修改密码", true, true);
    }


    @OnClick(R.id.btn_user_edit_pwd)
    public void onViewClicked() {
 mPresenter.getEditPassword(mEdtUserEditPwdOld.getText().toString(),
         mEdtUserEditPwdNew.getText().toString(),
         mEdtUserEditPwdRenew.getText().toString()
         );
    }


    @Override
    public void showEditPwdSuccess(String msg) {
        T.showShort("修改成功！");
        AM.user().loginOut();
        startActivity(new Intent(this, LoginActivity.class));
        finish();
    }

    @Override
    public void showError(String error) {
    T.showShort(error);
    }

    @Override
    public void showQiniuTokenSuccess(TokenBo data) {

    }

    @Override
    public void showUploadHashSuccess(String hash) {

    }



    @Override
    public void showUserInfoSuccess(UserInfoBo userInfoBo) {

    }

    @Override
    public void showAuthSuccess(String msg) {

    }

    @Override
    public void showSendCodeSuccess(String code) {

    }

    @Override
    public void showSendCodeError(String error) {

    }


}
